import Buff from '@/Buff';
import BuffUtil from '@/BuffUtil';
import BuffCommon from 'code/Core/Common/BuffCommon';
import UnitCommon from 'code/Core/Common/UnitCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/* 瘟疫打击 */
export default class DK_PlagueHit extends AbilityBase {
    static instance: DK_PlagueHit;
    buffType: AppBuffType = {
        id: 'buff_DK_PlagueHit',
        name: this.abilityName,
        ubertip: this.abilityData.Ubertip,
        art: this.art,
        interval: 1,
        dur: 12,
        onInterval: this.buffInterval.bind(this),
        targetAttach: 'origin',
        targetArt: 'Abilities\\Spells\\Other\\Parasite\\ParasiteTarget.mdl',
    };
    buffInterval(buff: Buff) {
        let source = buff.getCaster();
        let tar = buff.getParent();
        let lv = this.getAbilityLevel(source);
        let dmg = 21 * lv + UnitCommon.取法强(source) * (0.5 + 0.25 * lv);
        DamageSystemInstance.applyIceDamage(tar, source, dmg, this.id, true);
        DamageSystemInstance.applyPoisionDamage(tar, source, dmg, this.id, true);
    }
    constructor(id: string) {
        super(id);
        DK_PlagueHit.instance = this;
        this.init();
        se.onUnitSpellEffect(this.spellEffect.bind(this), this.id);
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        // BuffUtil.addBuff(target, this.buffType.id, source);
        BuffCommon.addBuff({ target, caster: source, buffTypeId: this.buffType.id, ablityId: this.id });
        DamageSystemInstance.applyAttackDamage(target, source, UnitCommon.取攻击(source), this.id);
    }
    spellEffect() {
        this.cast(GetUnitX(GetSpellTargetUnit()), GetUnitY(GetSpellTargetUnit()), GetTriggerUnit(), GetSpellTargetUnit());
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
}
